#ifndef _SCRIPTCOMP_H_
#define _SCRIPTCOMP_H_
#include <SECore/Ecs/Component.h>
#include <sol/sol.hpp>
#include <SECore/Reflect.h>
#include <SEngine/Script/ScriptState.h>
#include <SECore/ResourcePayload.h>

namespace SEngine
{
    struct ScriptComp : public Component<ScriptComp>
    {
        ENABLE_SERIALIZE(Component<ScriptComp>)
        ScriptComp(Actor & actor) : Component(actor) { m_enabled = false; }
        virtual void Attach() override;
        virtual void Detach() {}
        virtual void BeforeUpdate() override;
        virtual void OnUpdate(int delta) override;
        virtual void AfterUpdate() override;
        void Load(const std::string & path);
        void Reload();
        ResRef<ScriptState> lua;
    };

    REF_REGISTER_CLASS(ScriptComp,
        REF_REGISTER_FIELD(ScriptComp, lua)
    )
} // namespace SEngine


#endif